package exo1;

/**
 * Created with IntelliJ IDEA.
 * User: naberrad
 * Date: 14/10/13
 * Time: 14:22
 * To change this template use File | Settings | File Templates.
 */
public class Point2D {

    private double x;
    private double y;

    public Point2D(double x, double y) {
        this.x = x;
        this.y = y;
    }

    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }

    public void setX(double x) {
        this.x = x;
    }

    public void setY(double y) {
        this.y = y;
    }

    public void translate(double x, double y) {
        this.x = this.x + x;
        this.y = this.y + y;
    }

    public boolean isOrigin() {

        if (this.x == 0 && this.y == 0) {
            return true;
        } else {
            return false;
        }
    }

    public double distance(Point2D p2d) {
        double d;
        d=Math.pow(p2d.x-this.x,2)+Math.pow(p2d.y-this.y,2);
        d= Math.sqrt(d);
        return d;
    }
}
